package com.anonymous;

public class PersonTest {
//根据传入不同的人的类型，调用对应的read
    //方案一:
//    public void getRead(Man man){
//        man.read();
//    }
//    public void getRead(Woman woman){
//        woman.read();
//    }

    //方案二:多态
    public void getRead(Person person){
        person.read();
    }

    public static void main(String[] args){
        PersonTest test = new PersonTest();
//        Man man = new Man();
//        Woman woman = new Woman();
//        test.getRead(man);
//        test.getRead(woman);
//方案三:匿名内部类
        test.getRead(new Person() {
            @Override
            public void read() {
                System.out.println("男生喜欢看科幻类的书籍");
            }
        });
        test.getRead(new Person() {
            @Override
            public void read() {
                System.out.println("女生喜欢言情类的书籍");
            }
        });
    }
}
